package soul.domain.response;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import soul.entity.User;

/**
 * Created by admin on 2016/11/21.
 */
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown=true)
public class AuthParam {

    private User user;

    private VerificationCode code;

    private boolean notoken;

    @JsonCreator
    public AuthParam(@JsonProperty("notoken") boolean notoken,
                     @JsonProperty("login_name") String name,@JsonProperty("password") String password,
                     @JsonProperty("token") String token, @JsonProperty("verification_code") String verificationCode) {
        this.notoken = notoken;
        this.user = new User();
        this.user.setName(name);
        this.user.setPassword(password);
        this.code = new VerificationCode(token,verificationCode);
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public VerificationCode getCode() {
        return code;
    }

    public void setCode(VerificationCode code) {
        this.code = code;
    }

    public boolean isNotoken() {
        return notoken;
    }

    public void setNotoken(boolean notoken) {
        this.notoken = notoken;
    }

    public boolean needVerifyCode() {
        return !isNotoken();
    }
}
